package com.lishangshan.oas_system.model.dao.daymanagedao;

import com.lishangshan.oas_system.model.entity.schedule.ScheduleList;
import com.lishangshan.oas_system.model.entity.user.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DaymanageDao extends JpaRepository<ScheduleList, Long> {

    List<ScheduleList> findByUser(User user);

    List<ScheduleList> findByUsers(List<User> users);

    Page<ScheduleList> findByUsers(List<User> users, Pageable pa);

    Page<ScheduleList> findByUser(User user, Pageable pa);

    Page<ScheduleList> findByUserAndUsers(User user, List<User> users, Pageable pa);

    @Query("from ScheduleList as sc where sc.user = ?1 and sc.title like %?2%")
    Page<ScheduleList> findByUserAndVal(@Param("u") User u, @Param("val") String val, Pageable pa);
}
